package com.ruoyi.web.controller.api.user;

import lombok.RequiredArgsConstructor;

import javax.validation.constraints.*;

import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.system.domain.vo.PUserSignVo;
import com.ruoyi.system.domain.bo.PUserSignBo;
import com.ruoyi.system.service.IPUserSignService;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiOperation;

/**
 * 用户签到Controller
 *
 * @author ruoyi
 * @date 2022-08-05
 */
@Api(tags = {"前端-用户签到管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/userSign")
public class PUserSignApiController extends BaseController {

    private final IPUserSignService iPUserSignService;

    /**
     * 查询用户签到列表
     */
    @ApiOperation("查询用户签到列表")
    @GetMapping("/list")
    public TableDataInfo<PUserSignVo> list(PUserSignBo bo, PageQuery pageQuery) {
        return iPUserSignService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取用户签到详细信息
     */
    @ApiOperation("获取用户签到详细信息")
    @GetMapping("/{id}")
    public R<PUserSignVo> getInfo(@ApiParam("主键")
                                     @NotNull(message = "主键不能为空")
                                     @PathVariable("id") Long id) {
        return R.ok(iPUserSignService.queryById(id));
    }

    @ApiOperation("前端-用户签到")
    @RepeatSubmit()
    @PostMapping("/add")
    public R<Integer> add(@Validated(AddGroup.class) @RequestBody PUserSignBo bo) {
        return R.ok(iPUserSignService.insertByBo(bo));
    }
}
